<#cenluan title="投票" menu="vote" validate="true">
	<style>
		.progress-bar-1{background-color: #5cb85c; }
		.progress-bar-2{background-color: #5bc0de; }
		.progress-bar-3{background-color: #f0ad4e; }
		.progress-bar-4{background-color: #d9534f; }
		.progress-bar-5{background-color: #5cb85c; }
		.progress-bar-6{background-color: #5bc0de; }
		.progress-bar-7{background-color: #f0ad4e; }
		.progress-bar-8{background-color: #d9534f; }
		.progress-bar-9{background-color: #5cb85c; }
		.progress-bar-10{background-color: #5bc0de; }
	</style>
	<div class="row offcanvas-row offcanvas-row-right" id="offcanvas">
		<div class="col-sm-8">
			<ul class="nav nav-tabs mb20" role="tablist">
				<%if(isEmpty(show)||"new"==show){%>
					<li role="presentation" class="active"><a>最新</a></li>
				<%}else{%>
					<li role="presentation"><a href="/vote">最新</a></li>
				<%}%>
				<%if("hot"==show!){%>
					<li role="presentation" class="active"><a>最热</a></li>
				<%}else{%>
					<li role="presentation"><a href="/vote?show=hot">最热</a></li>
				<%}%>
				<%if(!isEmpty(session.user)){%>
					<%if("mine"==show!){%>
						<li role="presentation" class="active"><a>我的投票</a></li>
					<%}else{%>
						<li role="presentation"><a href="/vote?show=mine">我的投票</a></li>
					<%}%>
				<%}%>
				<li class="pull-right visible-xs">
					<a href="#offcanvas" data-toggle="offcanvas">&gt;&gt;</a>
				</li>
			</ul>
			<%for(vote in page.list){%>
				<div class="media" id="vote-${vote.id}">
				<%include("/vote/div.html",{vote:vote}){}%>
				</div>
				<%if(!voteLP.last){%><hr><%}%>
			<%}elsefor{%>
				<p>无可显示记录</p>
			<%}%>
			${pageLink}
		</div>
		<div class="col-sm-4 offcanvas-sidebar">
			<div class="panel panel-default">
				<div class="panel-body">
					<p class="text-center">来和小伙伴们一起起做做选择题吧！</p>
					<p class="text-center mb0">
						<a class="btn btn-primary" href="/vote/add">
							<span class="glyphicon glyphicon-plus"></span>发起投票
						</a>
					</p>
				</div>
			</div>
		</div>
	</div>
	<script>
		function del(id){
			if(!confirm("确定要删除这个投票吗？")){
				return;
			}
			$.getJSON("/vote/delete/"+id,function(json){
				if(json.ok){
					$("#vote-"+id).next("hr").remove();
					$("#vote-"+id).remove();
				}
			});
		}
		$(function() {
			$.each($(".vote-form"), function() {
				var $this = $(this);
				$this.validate({
					errorPlacement : function() {
					},
					submitHandler : function(form) {
						$(form).find(":submit").button("loading");
						$(form).ajaxSubmit(function(json) {
							if (json.ok) {
								$("#vote-" + $(form).data("id")).load("/vote/div/" + $(form).data("id"));
							} else {
								alert(json.msg);
								$(form).find(":submit").button("reset");
							}
						});
					}
				});
			});
		});
	</script>
</#cenluan>